import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Button, Input} from 'antd';
import { Switch,Route } from 'react-router-dom';
import user from '@pages/system/user'


import {withRouter,Link} from 'react-router-dom';
 //import User from '@pages/system/user'
// import role from '@pages/system/role'


class TableDemo extends Component {
    constructor(props) {
        super(props);
        this.state = {
            inputVal: '1234'
        }
      
    }

    componentWillMount() {
         console.log(this.props.routerData)
    }

    componentDidMount() {

    }
    method() {
        return {
            handleClickRest: ()=>{
                console.log('handleClickRest',  this.props)
                this.props.history.push({
                    pathname: '/react/tableDemo/sub'
                })
            }
        }
    }
    handleClickRest(e) {
        this.setState({
            inputVal:  e.target.value
        })
 
    }

    render() {
        return (
            <div>
                <Switch>
                    <Route path="/react/tableDemo/sub"  component={ user }/>
                </Switch>
               <Button type="primary" onClick={this.method().handleClickRest} style={{marginBottom:'20px'}}>Primary</Button>

                <Link to={'/react/tableDemo/sub'}>链接</Link>
               <Input placeholder="Basic usage" onChange={this.handleClickRest.bind(this)} value={this.state.inputVal}/>
               
                TableDemo
               <div>{this.state.inputVal}</div>

            </div>
        );
    }
}

const mapStateToProps = state => {
    return {
        routerData: state.base.routerData
    }
  }
 export default connect(mapStateToProps)(withRouter(TableDemo));
